package JZ;

/**
 * @Classname JZ54
 * @Description // https://leetcode-cn.com/problems/er-cha-sou-suo-shu-de-di-kda-jie-dian-lcof/ 树
 * @Date 2021/4/21 15:22
 * @Created by yin
 */
public class JZ54 {
    private  int ans,count;
    public int kthLargest(TreeNode root, int k) {
        dfs(root,k);
        return ans;
    }
    public void dfs(TreeNode root, int k){
        if(root.right!=null) dfs(root.right, k );
        if (k == ++count) {
            ans = root.val;
            return;
        }
        if(root.left!=null) dfs(root.left, k );
    }
}
